/**
* Copyright (c) 2013-2014, qtone Inc. All Rights Reserved.
*
* @author: tanghuaicheng
* Project Name: testuc
* $Id:   2017-01-11 10:54:07 $
*/
package cn.tang.tframe.common.base;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

public class PageBean<T> implements Serializable {

	private static final long serialVersionUID = 1L;

	private int totalRecords = 0; // 总记录数
	/**
	 * 当前页码
	 */
	private int currentPage;
	/**
	 * 总页数
	 */
	private int totalPage;
	/**
	 * 每页显示条数
	 */
	private int pageSize = 10;

	private List<T> dataList = new ArrayList<T>();

	public PageBean() {

	}

	public PageBean(int currentPage, int pageSize, List list, int totalRecords) {
		this.currentPage = currentPage;
		this.pageSize = pageSize;
		this.dataList = list;
		this.totalRecords = totalRecords;
		this.totalPage = (this.totalRecords - 1) / this.pageSize + 1;
	}

	public PageBean(List<T> dataList, int totalRecords) {
		this.dataList = dataList;
		this.totalRecords = totalRecords;
	}

	public List<T> getDataList() {
		return this.dataList;
	}

	public int getTotalRecords() {
		return this.totalRecords;
	}

	public void setDataList(List<T> dataList) {
		this.dataList = dataList;
	}

	public void setPageBean(int totalRecords, List<T> dataList) {

		if (totalRecords < 0) {
			throw new RuntimeException("总记录数不能小于0!");
		}
		// 设置总记录数
		this.totalRecords = totalRecords;

		this.dataList = dataList;
	}

	public void setTotalRecords(int totalRecords) {
		this.totalRecords = totalRecords;
		this.totalPage = (this.totalRecords - 1) / this.pageSize + 1;
	}

	public int getCurrentPage() {
		return currentPage;
	}

	public void setCurrentPage(int currentPage) {
		this.currentPage = currentPage;
	}

	public int getTotalPage() {
		return totalPage;
	}

	public void setTotalPage(int totalPage) {
		this.totalPage = totalPage;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}
}
